<!--
    试算页面 公共插件

    参数：
    planId         方案ID
    op             'add'=新增;'view'=查看;'edit'=修改

    方法:
    backPage        返回
 -->
<template>
    <card>
        <Alert>
            <Row style="text-align: right;">
                <Button icon="md-checkmark" type="success" v-show="'view'!== op" @click="processSubmission" :loading="submitLoading">提交</Button>
                <Button @click="backPage" icon="md-backspace" type="primary">返回</Button>
            </Row>
        </Alert>
        <Tabs type="card" :animated="false">
            <TabPane label="修改信息" name="proposal">
                <productUpdateInformation :parentParam="parentParam" :planId="planId" :op="op" @backResult="backResult" ref="child"/>
            </TabPane>
            <TabPane label="附件信息" name="name2" :disabled="op=='add'" >
                <productLaunchTabTwo :planId="planId" :op="op" />
            </TabPane>
        </Tabs>
    </card>
</template>
<script>
    //修改页面组件导入
    import productUpdateInformation from "./productUpdateInfomation.vue";
    import productLaunchTabTwo from "../common/common-attachment.vue";

    //产品修改方案查询
    import {processSubmission} from "@/projects/afs-core-business/api/afs-product/product-plan-approve/approve";

    export default {
        name: "product-launch-info",
        props: {
            //方案ID
            planId:{
                type:String,
            },
            //状态
            op:{
                type:String,
                required: true,
                default: 'view'
            },
            //修改信息
            parentParam:{
                type:Object,
            },
        },
        components: {
            productUpdateInformation,
            productLaunchTabTwo,
        },
        data() {
            return {
                submitLoading: false,
            }
        },
        methods: {
            //返回
            backPage() {
                this.$emit("backPage", "返回");
            },
            //提交
            processSubmission() {
                let flag = this.$refs['child'].validateForm();
                if (flag && this.planId!=null && this.planId!='') {
                    this.submitLoading = true;
                    let param = {
                        id:this.planId,
                    };
                    processSubmission(param).then(res => {
                        this.submitLoading = false;
                        if (res.code === "0000") {
                            this.$Message.success("操作成功");
                            this.backPage();
                        }
                    }).catch(() => {
                        this.submitLoading = false;
                    });
                } else {
                    this.$Message.warning("请保存方案信息！");
                }
            },
            //保存返回
            backResult(id){
                this.$emit('saveResult', id);
            },
        },
        mounted() {
        },
        created() {
        },
    };
</script>
